const fs = require("fs");
const path = require("path");

const version = process.argv[2] || "0.0.1";
const versionFilePath = path.join(__dirname, "../assets/scripts/controllers/Version.ts");
let versionFileContent = fs.readFileSync(versionFilePath, "utf-8");

const currentVersionMatch = versionFileContent.match(/version = "(.+)";/);

versionFileContent = versionFileContent.replace(
  /version = "(.+)";/,
  `version = "${version}";`
);

fs.writeFileSync(versionFilePath, versionFileContent);
console.log(
  `打包版本号为: ${version}  上一个版本号为: ${currentVersionMatch[1]}`
);
